package com.my.test.swing;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableCellRenderer;

public class FlightTableRenderer extends DefaultTableCellRenderer {

	@Override
	public Component getTableCellRendererComponent(JTable table,
            Object value,
            boolean isSelected,
            boolean hasFocus,
            int row,
            int column) {
		// TODO Auto-generated method stub
		setText(value.toString());
		if(column == 3){
			setHorizontalAlignment(SwingConstants.RIGHT);
		}else{
			setHorizontalAlignment(SwingConstants.LEFT);
		}
		if(((Integer)table.getValueAt(row, 3)).intValue() < 1){
			setBackground(Color.GRAY);
			setForeground(Color.WHITE);
		}else{
			if(isSelected){
				setBackground(Color.GREEN);
				setForeground(Color.BLACK);
			}else{
				setBackground(Color.WHITE);
				setForeground(Color.BLACK);
			}
		}
		return this;
	}
	
}
